<?php
#
# (c)2008 South Hill Calvary Chapel
#

include_once("./root.inc.php");
include("${root}/mysql/database_info.php");
include("${root}/common.php");
include("${root}/mysql/common.php");

function galleryview_elements($link, $image, $date, $title) {
	printf("\t\t<li>\n");
	$t = htmlspecialchars($title);
	printf("\t\t\t<img src='%s' alt='%s' title='%s' />\n", 
	       $image, $t, $t);
	printf("\t\t\t<div class='gv-panel-overlay'>\n");
	printf("\t\t\t\t<a class='gv-link' href='%s'></a>\n", $link);
	printf("\t\t\t</div>\n");
	printf("\t\t</li>\n");
}

function stay_connected($image, $link, $title, $tagline) {
	printf("\t\t\t<div class='blocks'>\n");
	printf("\t\t\t\t<div class='connected1'>\n");
	printf("\t\t\t\t\t<a href='%s' target='_blank'><img src='%s' alt='%s'/></a>\n", $link, $image, $title);
	printf("\t\t\t\t</div>\n");
	printf("\t\t\t\t<div>\n");
	printf("\t\t\t\t\t<a class='title' href='%s' target='_blank'><h5>%s</h5></a><a href='%s' target='_blank'>%s</a>\n", 
	$link, $title, $link, $tagline);
	printf("\t\t\t\t</div>\n");
	printf("\t\t\t</div>\n");	
}

$more = 
"<script type='text/javascript'>
	//Galleryview Slidedeck
	$(document).ready(function(){
		$('#myGallery').galleryView({
			transition_speed: 1200,
			transition_interval:  5000,
			easing: 'easeInOutBack',
			pause_on_hover: true,
			
			panel_width: 960,
			panel_height: 360,
			overlay_opacity: 0,
			overlay_position: 'bottom',
			//panel_scale: 'nocrop',
			show_panel_nav: false,
			show_overlays: true,
			
			frame_width: 96,
			frame_height: 36,
			filmstrip_size: 6,
			frame_opacity: 0.5,
			//filmstrip_style: 'show all',
			show_filmstip_nav: true,
			frame_gap: 5,
			filmstrip_position: 'bottom',
			
			animate_pointer: true
		});
	});
//AJAX Feed API Picasa Slideshow
	function LoadSlideShow() {
		var feed  = 'http://photos.googleapis.com/data/feed/base/user/southhillcalvary?kind=photo&alt=rss';
		var options = {
			displayTime:2000,
			transistionTime:600,
			scaleImages:false,
			maintainAspectRatio: true,
			linkTarget: google.feeds.LINK_TARGET_BLANK,
			fullControlPanel: true,
			fullControlPanelSmallIcons: true,
			fullControlPanelCursor: true,
			//centerBias: { topBias: -106, leftBias: -146},
			pauseOnHover: false
		};
		var ss = new GFslideShow(feed, 'picasaSlideshow', options);
	}
/*
* Use google.load() to load the AJAX Feeds API
* Use google.setOnLoadCallback() to call LoadSlideShow once the page loads
*/
	google.load('feeds', '1');
	google.setOnLoadCallback(LoadSlideShow);
</script>";


$title='Puyallup, WA Church';
$meta_key='Calvary Chapel, Christian, spiritual, spiritual needs, biblical, bible study, bible, bibles, theology, ministry, Scripture, scriptures, preach, preaching, sermon, sermons, study, child, children, parent, parents, single, family, truth, praise, worship, service, pray, prayer, love, faith, joy, peace, righteousness, God, Jesus, Christ, Jesus Christ, Holy Spirit, holiness';
$meta_desc='South Hill Calvary Chapel is a non-denominational church located in Puyallup, WA.  Our desire is to grow in our relationships with Jesus Christ and to make His Gospel known.';
print_html_head($title,$meta_key,$meta_desc);
print_java_head($more);

begin_body();



//Live Video Banner
live_video();

//GalleryView Slideshow
$table = "events";
connect_select_test($table);
$query="SELECT * FROM $table  WHERE homepage='1' ORDER BY start ASC";
$result=mysql_query($query) or die (mysql_error());
$num_rows=mysql_num_rows($result);

printf("<div class='clear'>&nbsp;</div>\n");

printf("<div class='galleryview' id='plainlist'>\n");
printf("\t<ul id='myGallery' >\n");

$now = time();
$i=0;
while ($i < $num_rows) {
	$date=mysql_result($result,$i,"start");
	$no_start=mysql_result($result,$i,"no_start");
	$php_start_time = strtotime($date);

	$date=mysql_result($result,$i,"end");
	$no_end=mysql_result($result,$i,"no_end");
	$php_end_time = strtotime($date);

	$php_end_day = date("z", $php_end_time);
	$php_start_day = date("z",$php_start_time);

	if ($now > $php_end_time) {
		$i++;
		continue;
	}

	if ($no_start) {
		$duration = 0;
	} else if ($no_end) {
		$date1 = date("l, F jS, g:i a", $php_start_time);
		$duration = $date1;
	} else if ($php_end_day != $php_start_day) {
		$date1 = date("l, F jS, g:i a", $php_start_time);
		$date2 = date("l, F jS", $php_end_time);
		$duration = $date1 . " - " . $date2;
	} else {
		$date1 = date("l, F jS, g:i a", $php_start_time);
		$date2 = date("g:i a", $php_end_time);
		$duration = $date1 . " - " . $date2;
	}
	$duration = strtoupper($duration);

	$title=strtoupper(htmlentities(mysql_result($result,$i,"title"), ENT_QUOTES));
	$announcement=mysql_result($result,$i,"announcement");
	$ministry=mysql_result($result,$i,"ministry");
	$flyer=mysql_result($result,$i,"flyer");
	$directions=mysql_result($result,$i,"directions");
	$id=mysql_result($result,$i,"id");
	$picture=mysql_result($result,$i,"picture");

	$link='/event/'.$id;

	galleryview_elements($link, $picture, $duration, $title);
	$i++; 
}
printf("\t</ul>\n");
printf("</div>\n");
mysql_close();

printf("<div id='col'>\n");
printf("\t<ul>\n");
printf("\t\t<li>\n");
printf("<h2 style='Text-align:left; margin-left: 22px; margin-top: 4px;'>Sunday</h2>\n");
connect_select_test("homepageMessages");
$result = mysql_query("SELECT * FROM `homepageMessages` WHERE `day`='Sunday' ORDER BY `id` DESC LIMIT 0,1");
$sundayMessage = mysql_fetch_array($result);
printf("<a href='%s'><img style='%s' src='%s'></img></a>", $sundayMessage['link'], "width:84%;margin:7px 22px;", $sundayMessage['image']);

printf("\t\t</li>\n");

printf("\t\t<li>\n");
printf("<h2 style='Text-align:left; margin-left: 22px; margin-top: 4px;'>Wednesday</h2>\n");
$result = mysql_query("SELECT * FROM `homepageMessages` WHERE `day`='Wednesday' ORDER BY `id` DESC LIMIT 0,1");
$sundayMessage = mysql_fetch_array($result);
printf("<a href='%s'><img style='%s' src='%s'></img></a>", $sundayMessage['link'], "width:84%;margin:7px 22px;", $sundayMessage['image']);

printf("\t\t</li>\n");

printf("\t\t<li>\n");
$table = "sermons";
connect_select_test($table);
printf("<h2 style='Text-align:left; margin-left: 10px; margin-top: 4px;'>Recent Messages</h2>\n");
$query="SELECT * FROM $table WHERE `service`LIKE'Sunday' || `service`LIKE'Wednesday' ORDER BY date DESC";
$result=mysql_query($query) or die (mysql_error());
sermon_snippet($result,3,$table);
printf("<div class='blocks'><a href='./sermon.php'><h5>Visit All Archived Messages</h5></a></div>\n");
mysql_close();
printf("\t\t</li>\n");

printf("\t</ul>\n");
printf("</div>\n");
printf("<div class='clear'>&nbsp;</div>\n");

end_body();
?>
